package com.baizhi.controller;

import com.baizhi.service.CmfzUserService;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/4/3 0003.
 */
@Controller
@RequestMapping("/user")
public class CmfzUserController {
    @Autowired
    private CmfzUserService cmfzUserService;
    private Logger logger= LoggerFactory.getLogger("CmfzUserController.class");

    @RequiresRoles(value = "admin")
    @RequestMapping("/showUsers")
    public @ResponseBody
    Map showUsers(Integer page, Integer rows) {
        Map map = cmfzUserService.queryAll(page, rows);
        return map;
    }

    @RequestMapping("/queryCountBySex1")
    public @ResponseBody List<Map> queryCountBySex1() {
        /*Map map = cmfzUserService.queryCountBySex();*/
        List<Map> maps = cmfzUserService.queryCountBySex();
        return maps;
    }

    @RequestMapping("/queryCountByProvince1")
    public @ResponseBody List<Map> queryCountByProvince1() {
        List<Map> maps = cmfzUserService.queryCountByProvince();
        return maps;
    }

    @RequestMapping("/queryCountByTime1")
    public @ResponseBody List<Map<String, Integer>> queryCountByTime1() {
        List<Map<String, Integer>> maps = cmfzUserService.queryCountByTime();
        return maps;
    }


    @RequestMapping("/queryCountByThread")
    public @ResponseBody Map queryCountByThread(){
        Map map = cmfzUserService.queryCountByThread();
        return map;
    }

    @RequiresRoles(value = "superadmin")
    @RequestMapping("/queryCountByFuture")
    public @ResponseBody Map queryCountByFuture(){
        Map map = null;
        try {
            map = cmfzUserService.queryCountByFuture();
            return map;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}
